package Opgave4_2;



public class TestExceptionHandlingMethods {
	public static void main(String[] args) {


		System.out.println("Kalder throwMyUncheckedException");
		try{
			throwMyUncheckedException();
		}
		catch( MyUncheckedException e){				//fanger og h�ndterer fejlen
			System.out.println("Fangede min unchecked exception"); 
		}
			 	
		new WeekDay(10); // Ignor�r fejlen
		
		try{
			WeekDay weekday = new WeekDay(8);
			}
			catch(invalidArgumentException e){ // fanger fejlen og sender en ny fejltype videre
				throw new MyUncheckedException(); // Viderekaster 
			}



	}

	// Kaldet til denne metode kaster fejlen af typen "myCheckedException"
	public static void throwMyCheckedException() throws MyCheckedException {
		throw new MyCheckedException();	
	}

	public static void throwMyUncheckedException() {
		throw new MyUncheckedException();
	}
}


class WeekDay{
	private int day;
	public WeekDay( int day ){
		if( day < 1 || day > 7 ){
			String msg = day + " is not a legal day";
			throw new invalidArgumentException( msg );
		}
		else{
			this.day = day;
		}
	}
}


